home *** CD-ROM | disk | FTP | other *** search
- Path: gryphon.phoenix.net!usenet
- From: brucew@phoenix.net (Bruce Wedding)
- Newsgroups: comp.lang.c,alt.msdos.programmer
- Subject: Re: Two strange C problems.
- Date: Mon, 08 Jan 1996 03:51:13 GMT
- Organization: BranPaul Systems
- Message-ID: <4cq1vu$d8c@gryphon.phoenix.net>
- References: <4cojb2$qog@lugb.latrobe.edu.au>
- NNTP-Posting-Host: dial133.phoenix.net
- X-Newsreader: Moe's Newsreader
-
- cs102238@lux.latrobe.edu.au (Gregary John Boyles ) wrote:
-
- >I have two C problems.
-
- Sorry, I don't feel like taking the time for problem #1.
-
- >PROBLEM 2 :
-
- >const escape=27;
- >const cr=13;
- >const bs=8;
-
- In C++, this is ok. In C, you have to use:
- #define ESC 27
- #define CR 13
-
- etc.
-
- >while (ch!=cr)
- Then all these loops will work.
-
- >If I replace the 27 with \27' or the 13 with '\13' then these loops don't
- >work i.e. an infinite loop results. WHY?
-
- Because the character will never equal those values, simple enough.
-
- >Also if I want to do somthing like this : puts("\24 \25"); which should
- >print the up and down arrows on the screen (ASCII 24 and 25), but no, it
- >prints some other ASCII characters. As far as I can tell C has its own
- >unique character table, at least for the control characters. WHY?
-
- It uses the standard ASCII character set, at least in DOS. If you
- want to print those characters, just use those values. The \
- character is only used with the following chars ( ",\,n,r,f,0). Well,
- that is probably not all of them, but those are the most important.
- If you want to print those characters above, do this:
-
- print("%c%c", 24,25);
- or
- char a[3] = { 24, 25, '\0'};
- puts(a);
-
- >Sometimes I wonder whether some one needs to go back an rewrite
- >the damn language so that it works sensibly and predictably like
- >Pascal can be relied upon to do.
-
- I hate to say it, but you are asking for it. Maybe one needs to learn
- the damn language so they can program sensibly and predictably. At
- least there is a standard for C. Pascal has no standard and will
- behave VERY unpredictably from system to system.
-
-
-
- Bruce D. Wedding Have Compiler, Will Travel!
- Perspicacious Programming Performed Promptly
- Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
-
-